package com.dongline.test.gongtonghaoyou;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FriendMapper extends Mapper<LongWritable, Text,Text,Text> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line=value.toString();
        String[] person_friends=line.split(":");

        String[] friends=person_friends[1].split(",");
        String person=person_friends[0];

        for (String friend:friends)
        {
            context.write(new Text(friend),new Text(person));
        }
    }
}
